package xyz.cerberu.cet.search.configuration;

import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author β世界
 * Created on 11:06
 * @Description solr的环境配置,当我们的属性上配合了solr为核心的搜索时，使用
 */
@Configuration
@ConditionalOnProperty(name = {"global.search-living"},havingValue = "solr")
public class SolrConfig {

    /** 装载solr服务的url **/
    @Value("${global.solr-url}")
    private String solrUrl;

    /**
     * @author β世界 on 20:59 2021/3/20
     * 创建一个solr的客户端
     * @return org.apache.solr.client.solrj.SolrClient
     **/
    @Bean
    public SolrClient solrClient(){
        return new HttpSolrClient.Builder(solrUrl).build();
    }

}
